// myPages/process/child/appointment/appointment.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    myOptions: {
      type: Object,
      value: '',
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    problem: "", //问题
    introduction: "", //介绍
  },

  /**
   * 组件的方法列表
   */
  methods: {
    commit: function() {
      var myEventDetail = {
        toUserId: this.properties.myOptions.toUserId, //导师id
        price: this.properties.myOptions.price, //价钱
        meetType: this.properties.myOptions.type, //越聊方式
        topicId: this.properties.myOptions.topicId, //购买话题
        question: this.data.problem, //问题
        introduction: this.data.introduction //自我介绍
      }
      if (myEventDetail.question.length < 1 || myEventDetail.introduction.length<1){
        wx.showToast({
          title: "问题/自我介绍为必填项",
          icon: 'none'
        });
        return false;
      } else if (myEventDetail.question.length > 500 || myEventDetail.introduction.length > 500){
        wx.showToast({
          title: "问题/自我介绍限500字",
          icon: 'none'
        });
      } else{
        this.triggerEvent('myeventA', myEventDetail);
      }
    },
    inputProblemChange(e) {
      this.setData({
        problem: e.detail.value
      })
    },
    inputIntroductionChange(e) {
      this.setData({
        introduction: e.detail.value
      })
    }
  }

  /*提交触发父组件*/
})